package com.CST.controller.ys;

import com.CST.common.api.ResultObject;
import com.CST.dto.ys.AppealDTO;
import com.CST.dto.ys.DetailDTO;
import com.CST.dto.ys.YsDetailDTO;
import com.CST.service.ys.YsAppealRecordService;
import com.CST.vo.ys.YsIndexDetailsVO;
import com.CST.service.ys.YsIndexDetailService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author qtx
 * @since 2023-04-21
 */
@RestController
@RequestMapping("/ysIndexDetail")
@Api(tags = "管理业务量配套指标")
public class YsIndexDetailController {

    private  final YsIndexDetailService service;
    private final YsAppealRecordService recordService;
    public YsIndexDetailController(YsIndexDetailService service, YsAppealRecordService recordService) {
        this.service = service;
        this.recordService = recordService;
    }

    @ApiOperation("管理-业务量配套指标")
    @PostMapping("/listIndexInfo")
    public ResultObject<PageInfo<YsIndexDetailsVO>> listIndexInfo(@RequestBody YsDetailDTO dto){
        return ResultObject.success(service.listIndexInfo(dto));
    }

    @ApiOperation("导出")
    @PostMapping("/exportIndexList")
    public ResultObject<String> exportIndexList(@RequestBody YsDetailDTO dto, HttpServletResponse response){
        return ResultObject.success(service.exportIndexList(dto,response));
    }

    @ApiOperation("申诉回显-管理-业务量配套指标")
    @PostMapping("/get_obj")
    public ResultObject<YsIndexDetailsVO> getIndexById(@RequestBody DetailDTO params){
        return ResultObject.success(service.getIndexById(params.getNum()));
    }

    @ApiOperation("添加申诉")
    @PostMapping("/add")
    public ResultObject<Integer> addAppeal(@RequestBody AppealDTO dto, HttpServletRequest request) throws IOException {
        dto.setSource(4);
        return ResultObject.success(recordService.addAppeal(dto,request));
    }

}
